package edu.ncu.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface GreatDao {
    /**
     * 根据动态的id设置对应动态的点赞数+1
     * @param publishId
     */
    @Update("update publish set likeNum=likeNum+1 where id=#{publishId}")
    boolean setGreatOfPublish(int publishId) ;

    @Update("update photo set likeNum=likeNum+1 where id=#{photoId}")
    boolean setGreatOfPhoto(int photoId) ;

    @Update("update discuss_1 set likeNum=likeNum+1 where cid=#{commentId}")
    boolean setGreatOfComment(int commentId) ;



    /**
     * 根据用户id和动态id设置用户点赞
     * 往点赞表中插入一条数据
     * gOType=0,
     * @param publishId
     * @param userId
     */
    // @Insert("insert into great_1 where gOId=#{publishId} and gOType=0 and uId=#{userId}")
    @Insert("insert into publish_great(userId,publishId) values(#{userId}, #{publishId});")
    boolean insertGreatOfPublish(@Param("publishId") int publishId, @Param("userId")int userId) ;

    @Insert("insert into photo_great(userId,photoId) values(#{userId}, #{photoId});")
    boolean insertGreatOfPhoto(@Param("photoId")int photoId, @Param("userId")int userId) ;

    @Insert("insert into great_1 where gOId=#{commentId} and gOType=2 and uId=#{userId}")
    boolean insertGreatOfComment(@Param("commentId")int commentId, @Param("userId")int userId) ;



}
